//
//  NewTransferOutViewModel.m
//  Wallet
//
//  Created by  ztryxh on 2018/6/13.
//  Copyright © 2018年 ebo. All rights reserved.
//

#import "NewTransferOutViewModel.h"
#import "AddressModel.h"
#import "CoinModel.h"
#import "CoinDetailModel.h"
#import "TransferOutModel.h"
@implementation NewTransferOutViewModel
#pragma mark Pricacy
-(instancetype)init
{
    
    self=[super init];
    if(self){
        
        [self setupViewModel];
        
    }
    return self;
}
-(void)setupViewModel{
    
     kWeakSelf(weakSelf);
    
    self.coinListCommand=[[RACCommand alloc]initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input) {
        return weakSelf.coinListSignal;
    }];
    
    self.blackNameListCommand=[[RACCommand alloc]initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input) {
        
        return weakSelf.blackListSignal;
    }];
    
    self.coinDetailInfoCommand=[[RACCommand alloc]initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input) {
        return weakSelf.coinDetailInfoSignal;
    }];
    
    self.addresssListCommand=[[RACCommand alloc]initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input) {
        return weakSelf.addressSignal;
    }];
    
    self.turnOutCommand=[[RACCommand alloc]initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input) {
        
        return weakSelf.turnOutSignal;
    }];
    
    
    
    
}
-(RACSignal *)coinListSignal{
    
//    RACSignal *signal=[RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
//
//        [[BaseEngine shareEngine]postRequestWithPara:nil path:kSetURL(kCoinList) success:^(id responseObject) {
//
//            if([[responseObject valueForKey:@"error"] integerValue]==0){
//
//
//                NSArray *arr=[responseObject valueForKey:@"data"];
//                NSArray *myarr;
//                myarr =
//                [[[arr.rac_sequence map:^id(NSDictionary * value) {
//
//
//                    CoinModel *model = [CoinModel new];
//                    [model yy_modelSetWithDictionary:value];
//                    return model;
//
//
//                }] array]mutableCopy];
//                [subscriber sendNext:myarr];
//                [subscriber sendCompleted];
//
//            }else{
//                [subscriber sendNext:@""];
//                [subscriber sendCompleted];
//            }
//
//        } failure:^(id error) {
//
//            [subscriber sendNext:@""];
//            [subscriber sendCompleted];
//        }];
        return nil;
//
//    }];
//
//    return signal;
    
}
-(RACSignal *)blackListSignal
{
    
//    RACSignal *signal=[RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
    
//        [[BaseEngine shareEngine]postRequestWithPara:self.blackNameListPara path:kSetURL(kBlackTransferAddresses) success:^(id responseObject) {
//
//            if([[responseObject valueForKey:@"error"] integerValue]==0){
//
//
//                NSArray *arr=[responseObject valueForKey:@"data"];
//                [subscriber sendNext:arr];
//                [subscriber sendCompleted];
//
//            }else{
//                [subscriber sendNext:@""];
//                [subscriber sendCompleted];
//            }
//
//        } failure:^(id error) {
//
//            [subscriber sendNext:@""];
//            [subscriber sendCompleted];
//            [MBProgressHUD showErrorWithText:@"网络请求失败！"];
//        }];
        return nil;
//
//    }];
//
//    return signal;
}
-(RACSignal *)coinDetailInfoSignal{
    
//    RACSignal *signal=[RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
    
//        [[BaseEngine shareEngine]postRequestWithPara:self.coinDetailPara path:kSetURL(kCoinDetails) success:^(id responseObject) {
//
//            if (![[responseObject valueForKey:@"error"] intValue]) {
//                NSDictionary *dic = [responseObject valueForKey:@"data"];
//                CoinDetailModel *model = [[CoinDetailModel alloc]init];
//                [model setValuesForKeysWithDictionary:dic];
//                [subscriber sendNext:model];
//                [subscriber sendCompleted];
//
//            }
//            else{
//
//                [subscriber sendNext:@""];
//                [subscriber sendCompleted];
//            }
//
//        } failure:^(id error) {
//
//            [MBProgressHUD showErrorWithText:@"网络请求失败"];
//            [subscriber sendNext:@""];
//            [subscriber sendCompleted];
//        }];
        return nil;
//    }];
//    return signal;
}
-(RACSignal *)addressSignal{
    
//    RACSignal *signal=[RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
    
//        [[BaseEngine shareEngine]postRequestWithPara:nil path:kSetURL(kTransferAddressselect) success:^(id responseObject) {
//
//            if (![[responseObject valueForKey:@"error"] intValue]) {
//                NSArray *arr = [responseObject valueForKey:@"data"];
//                NSArray *myArr=[[[arr.rac_sequence map:^id _Nullable(NSDictionary * value) {
//
//                    AddressModel *model=[AddressModel new];
//                    [model yy_modelSetWithDictionary:value];
//                    return model;
//
//                }]array]mutableCopy]  ;
//                [subscriber sendNext:myArr];
//                [subscriber sendCompleted];
//
//            }
//            else{
//
//                [subscriber sendNext:@""];
//                [subscriber sendCompleted];
//            }
//
//        } failure:^(id error) {
//
//            [MBProgressHUD showErrorWithText:@"网络请求失败"];
//            [subscriber sendNext:@""];
//            [subscriber sendCompleted];
//        }];
        return nil;
//    }];
//    return signal;
    
}
-(RACSignal *)turnOutSignal
{
//    RACSignal *signal=[RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
//
//        [[BaseEngine shareEngine]postRequestWithPara:self.turnOutPara path:kSetURL(kTransferOut) success:^(id responseObject) {
//
//            if (![[responseObject valueForKey:@"error"] intValue]) {
//                NSString *status = [responseObject valueForKey:@"data"];
//                [subscriber sendNext:status];
//                [subscriber sendCompleted];
//
//            }
//            else{
//
//                [subscriber sendNext:@""];
//                [subscriber sendCompleted];
//            }
//
//        } failure:^(id error) {
//
//            [MBProgressHUD showErrorWithText:@"网络请求失败"];
//            [subscriber sendNext:@""];
//            [subscriber sendCompleted];
//        }];
        return nil;
//    }];
//    return signal;

}
@end
